﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace StockholmsStad.Windows.UI
{
    /// <summary>
    /// Interaction logic for ExceptionWindow.xaml
    /// </summary>
    public partial class ExceptionWindow : Window
    {
        public ExceptionWindow()
        {
            InitializeComponent();

            this.Loaded += new RoutedEventHandler(ExceptionWindow_Loaded);
        }

        void ExceptionWindow_Loaded(object sender, RoutedEventArgs e)
        {
            expanderControl.Expanded += new RoutedEventHandler(expanderControl_IsExpandedChanged);
            expanderControl.Collapsed += new RoutedEventHandler(expanderControl_IsExpandedChanged);
            closeButton.Click += new RoutedEventHandler(closeButton_Click);

            RefreshExpanderConbtrol();
        }

        private void RefreshExpanderConbtrol()
        {
            expanderControl.Visibility = extendedMessageTextBox.Text != String.Empty ? Visibility.Visible : Visibility.Hidden;
        }

        void expanderControl_IsExpandedChanged(object sender, RoutedEventArgs e)
        {
            if (expanderControl.IsExpanded)
                this.Height += 120;
            else
                this.Height -= 120;
        }

        void closeButton_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        public string MessageText
        {
            get { return messageTextBlock.Text; }
            set { messageTextBlock.Text = value; }
        }

        public string ExtendedMessageText
        {
            get { return extendedMessageTextBox.Text; }
            set { extendedMessageTextBox.Text = value; RefreshExpanderConbtrol(); }
        }
    }
}
